{include file="common/_header"}

<body>

    <div class="x-body layui-anim layui-anim-up">
        <form class="layui-form">
            <input type="hidden" name="manager_id" value="{$data.manager_id|default=0}">
            <input type="hidden" name="form" value="submit">
            <table id="table" lay-size="sm" class="tables layui-table">
                <colgroup>
                    <col width="100">
                    <col width="250">
                    <col width="100">
                    <col width="250">
                </colgroup>
                <tbody>
                <tr>
                    <td><span class="x-red">*</span>管理员名称</td>
                    <th><input type="text" name="real_name" placeholder="请输入" value="{$data.data.real_name}" lay-verify="real_name" autocomplete="off" class="layui-input"></th>
                    <td>状态</td>
                    <th>
                        <select name="status">
                            <option value="1" {if $data.data.status == 1}selected{/if}>正常</option>
                            <option value="2" {if $data.data.status == 2}selected{/if}>停用</option>
                        </select>
                    </th>
                </tr>
                <tr>
                    <td><span class="x-red">*</span>管理员账号</td>
                    <th><input type="text" name="user_account" placeholder="请输入" value="{$data.data.user_account}" id="user_name" lay-verify="user_account" autocomplete="off" class="layui-input"></th>
                    <td>密码</td>
                    <th><input type="password" name="user_pass" id="user_pass"  placeholder="不填密码默认456789(无密码时)" autocomplete="off" class="layui-input"></th>
                </tr>
                </tbody>
            </table>
            <div style="margin-top: 30px; margin-right: 20px; text-align: right">
                <button type="button" lay-submit lay-filter="add" class="layui-btn" >立即提交</button>
            </div>
        </form>
    </div>
</body>

<script>
    layui.use('form', function(){
        var form = layui.form;

        form.verify({
            real_name: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!value){
                    return '管理员名称不能为空'
                }
                if(!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)){
                    return '管理员名称不能有特殊字符';
                }
                if(/(^\_)|(\__)|(\_+$)/.test(value)){
                    return '管理员名称首尾不能出现下划线\'_\'';
                }
                // if(/^\d+\d+\d$/.test(value)){
                //     return '用户名不能全为数字';
                // }
            },
            user_account: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!value){
                    return '账号不能为空'
                }
                if(!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)){
                    return '账号不能有特殊字符';
                }
                if(/(^\_)|(\__)|(\_+$)/.test(value)){
                    return '账号首尾不能出现下划线\'_\'';
                }
                // if(/^\d+\d+\d$/.test(value)){
                //     return '用户名不能全为数字';
                // }
            },

        });


        form.on('submit(add)', function (data) {
            $.ajax({
                'url': 'boxemanager',
                'type': 'post',
                'data': data.field,
                'dataType': 'json',
                success: function (data) {
                    if(data.code == 1){
                        layer.msg(data.msg, {
                            icon: 6,
                            time: 800,
                        },function () {
                            window.parent.location.reload();
                        })
                    }
                }
            });
        })
    });

</script>

{include file="common/_bottom"}